<template>
  <div v-if="model.id!=null"
       style="width: calc(100% - 40px); margin-top: 24px;margin-left: 20px;margin-right: 20px; background-color: #fff; min-height: calc(100vh - 120px);font-size: 16px;">
    <div style="text-align: center;font-size: 20px;font-weight: bold;color: #505968;">
      <span>{{ model.title }}</span>
    </div>
    <div style="text-align: center;margin-bottom: 32px;margin-top: 16px;font-size: 14px;color: #505968;opacity: 0.8;">
      <span style="margin-right: 50px;">发布时间：{{ model.publish_time }}</span><span style="margin-left: 50px;">作者：{{ model.author }}</span>
    </div>
    <div v-html="model.content">
    </div>
    <elm-fileview v-if="module_name!=null" :module_name="module_name" :rel_id="model.id" tip="相关附件" style="margin-top: 40px;"></elm-fileview>

  </div>
</template>

<script>
export default {
  data() {
    return {
      loading:true,

      model:{},
      module_name:null,
    }
  },
  props: {
    data_id: { type: String, default: null },
    page_type: { type: String, default: null },//news、tzgg
  },
  created() {},
  mounted() {
    this.getData();
  },
  /*
  watch: {
    data_id: {
      async handler(newval, oldval) {
        if (newval != null && newval!='') {
          if (newval != oldval) {
            this.getData();
          }
        }
      },
      immediate: true
    }
  },
  */
  methods: {
    async getData() {
      this.model = {};
      this.module_name = null;
      if(this.page_type =='news') {
        this.module_name="biz_cms_news_files";
        this.model = await elm.post("/business/my/GetNews", {id: this.data_id});
        this.model.publish_time = this.model.publish_time==null?'':this.model.publish_time.split('T')[0];
      }
      else if(this.page_type =='tzgg') {
        this.module_name="biz_cms_notice_files";
        this.model = await elm.post("/business/my/GetNotice", {id: this.data_id});
        console.log(this.model);
        this.model.publish_time = this.model.publish_time==null?'':this.model.publish_time.split('T')[0];
      }
      else{return;}

    }
  }
}
</script>